using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableEquipDao:DaoBase<TableEquip>
    {
        public override void AddPrimaryIndex(TableEquip model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableEquip.txt";
        }

        protected override TableEquip ParseRowData(string[] rowData)
        {
            TableEquip data = new TableEquip();
			data.id = rowData [0];

            if (string.IsNullOrEmpty(rowData[1]))
            {
                data.quality = 0;
            }
            else
            {
                data.quality = int.Parse(rowData[1]);
            }

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.type = 0;
            }
            else
            {
                data.type = int.Parse(rowData[2]);
            }
			data.outfitId = rowData [3];
			data.icon = rowData [4];
			data.pictrue = rowData [5];

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.attBase = 0;
            }
            else
            {
                data.attBase = double.Parse(rowData[6]);
            }

            if (string.IsNullOrEmpty(rowData[7]))
            {
                data.mdefBase = 0;
            }
            else
            {
                data.mdefBase = double.Parse(rowData[7]);
            }

            if (string.IsNullOrEmpty(rowData[8]))
            {
                data.hpBase = 0;
            }
            else
            {
                data.hpBase = double.Parse(rowData[8]);
            }

            if (string.IsNullOrEmpty(rowData[9]))
            {
                data.pdefBase = 0;
            }
            else
            {
                data.pdefBase = double.Parse(rowData[9]);
            }

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.attGrow = 0;
            }
            else
            {
                data.attGrow = double.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.mdefGrow = 0;
            }
            else
            {
                data.mdefGrow = double.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.hpGrow = 0;
            }
            else
            {
                data.hpGrow = double.Parse(rowData[12]);
            }

            if (string.IsNullOrEmpty(rowData[13]))
            {
                data.pdefGrow = 0;
            }
            else
            {
                data.pdefGrow = double.Parse(rowData[13]);
            }

            if (string.IsNullOrEmpty(rowData[14]))
            {
                data.sellPrice = 0;
            }
            else
            {
                data.sellPrice = int.Parse(rowData[14]);
            }

            if (string.IsNullOrEmpty(rowData[15]))
            {
                data.hole1 = 0;
            }
            else
            {
                data.hole1 = int.Parse(rowData[15]);
            }

            if (string.IsNullOrEmpty(rowData[16]))
            {
                data.hole2 = 0;
            }
            else
            {
                data.hole2 = int.Parse(rowData[16]);
            }

            if (string.IsNullOrEmpty(rowData[17]))
            {
                data.hole3 = 0;
            }
            else
            {
                data.hole3 = int.Parse(rowData[17]);
            }

            if (string.IsNullOrEmpty(rowData[18]))
            {
                data.hole4 = 0;
            }
            else
            {
                data.hole4 = int.Parse(rowData[18]);
            }

            return data;
        }



        public override void AddTwoIndex(TableEquip model)
        {
            string key = GetUnionKey(model.quality.ToString(),model.type.ToString());
            if (!cacheTwoIndex.ContainsKey(key))
            {
                cacheTwoIndex[key] = new List<TableEquip>();
            }
            cacheTwoIndex[key].Add(model);
        }


    }

}
